﻿<div class="panel panel-default">
    <div class="panel-heading">
        <h2 ng-if="!vm.isEditMode">{{::vm.translate.get('Create Product Display Widget')}}</h2>
        <h2 ng-if="vm.isEditMode">{{::vm.translate.get('Edit Product Display Widget')}}</h2>
    </div>
    <div class="panel-body">
        <form name="pageForm" class="form-horizontal">
            <div class="col-sm-offset-2 bg-danger" ng-show="vm.validationErrors">
                <ul>
                    <li ng-repeat="error in vm.validationErrors">{{error}}</li>
                </ul>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Name')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.widgetInstance.name" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Zone')}}</label>
                <div class="col-sm-10">
                    <select ng-model="vm.widgetInstance.widgetZoneId" class="form-control"
                            ng-options="zone.id as zone.name for zone in vm.widgetZones"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish Start')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishStart" is-open="vm.datePickerPublishStart.open" datepicker-options="vm.datePickerPublishStart.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishStart')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish End')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishEnd" is-open="vm.datePickerPublishEnd.open" datepicker-options="vm.datePickerPublishEnd.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishEnd')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Category')}}</label>
                <div class="col-sm-10">
                    <select class="form-control" ng-model="vm.widgetInstance.setting.categoryId"
                            ng-options="category.id as category.name for category in vm.categories">
                        <option value="">All categories</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Number of Products')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.widgetInstance.setting.numberOfProducts" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Order By')}}</label>
                <div class="col-sm-10">
                    <select ng-model="vm.widgetInstance.setting.orderBy" class="form-control"
                            ng-options="sort.id as sort.name for sort in vm.sorts"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Display Order')}}</label>
                <div class="col-sm-10">
                    <input type="number" name="displayOrder" ng-model="vm.widgetInstance.displayOrder" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" ng-model="vm.widgetInstance.setting.featuredOnly"> {{::vm.translate.get('Is Featured Products Only')}}
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button class="btn btn-primary" ng-click="vm.save()"><span class="glyphicon glyphicon-ok"></span> {{::vm.translate.get('Save')}}</button>
                    <button ui-sref="widget" class="btn btn-default">{{::vm.translate.get('Cancel')}}</button>
                </div>
            </div>
        </form>
    </div>
</div>